<?php

// Do not delete these lines
	if (!empty($_SERVER['SCRIPT_FILENAME']) && 'comments.php' == basename($_SERVER['SCRIPT_FILENAME']))
		die ('Please do not load this page directly. Thanks!');

	if ( post_password_required() ) { ?>

<p class="nocomments">Password protected.</p>
<?php
		return;
	}
?>

<div id="comment_list">
<?php include_once TEMPLATEPATH.'/comment_list.php'; ?>
</div>

<?php if ('open' == $post->comment_status) : ?>
<div id="respond">
	<?php if (is_page('guestbook')): ?>
	<h3>发表留言</h3>
	<?php else: ?>
    <h3>发表评论</h3>
	<?php endif; ?>

    <div class="cancel-comment-reply"> 
      <?php cancel_comment_reply_link("[ 取消回复 ]");?>
    </div>
    <?php if ( get_option('comment_registration') && !$user_ID ) : ?>
    <p><?php print 'You must be'; ?> <a href="<?php echo get_option('siteurl'); ?>/wp-login.php?redirect_to=<?php echo urlencode(get_permalink()); ?>"><?php print 'Logged in'; ?></a> <?php print 'to post comment'; ?>.</p>
    <?php else : ?>
    <form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform">
      <?php if ( $user_ID ) : ?>
      <p>以身份 <a href="<?php echo get_option('siteurl'); ?>/wp-admin/profile.php"><?php echo $user_identity; ?></a> 留言 → [ <a href="<?php echo wp_logout_url(get_permalink()); ?>" title="我不想用这个用户留言">取消登录</a> ]</p>
      <?php else : ?>
	    <p>
		<?php if ( $comment_author != "" ) : ?>	    
			<?php printf(__('欢迎您回来，<strong>%s</strong>，', 'blocks'), $comment_author) ?>
			<?php echo comment_count($comment_author_email); ?>
			<span id="show_author_info">
			<a href="javascript:show();">[更改身份]</a>
			</span>
			<span id="hide_author_info">
			<a href="javascript:hide();">[隐藏身份]</a>
			</span>				
		<?php endif; ?>
        </p>
		<div id="author_info">		 
			  <p>
				<input class="author" type="text" value="<?php echo $comment_author; ?>" name="author" id="author" size="25" tabindex="1"/>
				<label for="author">名称(你说的)<?php if ($req) echo "(少不了的)"; ?>
				</label>
			  </p>
			  <p>
				<input class="email" type="text"  value="<?php echo $comment_author_email; ?>" name="email" id="email" size="25" tabindex="2"/>
				<label for="email">邮箱(我看的)<?php if ($req) echo " (少不了的)"; ?></label>
			  </p>
			  <p>
				<input class="url" type="text" value="<?php echo $comment_author_url; ?>" name="url" id="url" size="25" tabindex="3"/>
				<label for="url">网址(你懂的)</label>
			  </p>
	    </div>
	  	<?php if ( $comment_author != "" ) : ?>
			<script type="text/javascript">
			 function setStyleDisplay(id, status)
			 {
			   document.getElementById(id).style.display = status;
			 }
			 function show()
			 {
				 setStyleDisplay('author_info','');
				 setStyleDisplay('show_author_info','none');
				 setStyleDisplay('hide_author_info','');
			 }
			 function hide()
			 {
				setStyleDisplay('author_info','none');
				setStyleDisplay('show_author_info','');
				setStyleDisplay('hide_author_info','none');
			 }
			 hide();
			 </script>				
		<?php endif; ?>
		
      <?php endif; ?>
	  <div id="smiley_ajax"></div>
            <script type="text/javascript" src="<?php bloginfo('template_directory'); ?>/functions/comment-maxlength.js"></script>
			<script type="text/javascript">
			$(function () {
					$('textarea.limited').maxlength({
						'feedback' : '.charsLeft',
						'useInput' : true
					});
			});
			</script>
      <p>
	    <p>		
		<a href="javascript:italicize();" title="评论中在[private]和[/private]中的内容只有管理员可见">[ 悄悄话 ]</a>
	    <script type="text/javascript" src="<?php bloginfo('template_directory'); ?>/functions/comment_visible.js"></script>
		你还可以输入 <span class="charsLeft" style = "font-size:14px; font-weight:bold;">250</span> 字
		</p>
		<br/>
        <textarea name="comment" class="limited" id="comment" tabindex="4" onkeydown="if(event.ctrlKey&&event.keyCode==13){document.getElementById('submit').click();return false};"></textarea>
      </p>
      <p>
	    <input type="hidden" name="maxlength" value="250" />
        <input class="submit" name="submit" type="submit" id="submit" tabindex="5" value="提交评论" /> (Ctrl+Enter快捷回复)
        <?php comment_id_fields(); ?>      
        <?php do_action('comment_form', $post->ID); ?>		
	  </p>
    </form>
    <?php endif; // If registration required and not logged in ?>
</div>
<?php endif; // if you delete this the sky will fall on your head ?>